﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Agresso.Interface.Layer.Domain
{
    public class jVendors
    {
        public int jVendorsID;// int IDENTITY(1,1) NOT NULL,
        public string Client;// varchar(25) NULL,
        public string VendorId;// varchar(25) NULL,
        public string VendorName;// varchar(80) NULL,
        public string CurrencyCode;// varchar(3) NULL,
        public string Country;// varchar(80) NULL,
        public string VendorAddress1;// varchar(80) NULL,
        public string VendorAddress2;// varchar(80) NULL,
        public string VendorPhone;// varchar(25) NULL,
        public string VendorFax;// varchar(25) NULL,
        public string VendorEmailID;// varchar(80) NULL,
        public string PaymentTerms;// varchar(25) NULL,
        public string PaymentMethod;// varchar(25) NULL,
        public string EnabledFlag;// varchar(1) NULL,
        public DateTime AddedOn;// datetime NULL,
        public int PickedUpFlag;// int NULL,
        public DateTime PickedUpAt;// datetime NULL,
        public string ShortName;//varchar(10) NULL,
        public string Description;//varchar(255) NULL,
        public string ResultDetails;// varchar(60) NULL,
        public string ExecutionID;// varchar(50) NULL,
        public jVendors(SqlDataReader rd)
        {
            jVendorsID = rd["jVendorsID"] is DBNull ? jVendorsID : Convert.ToInt32(rd["jVendorsID"]);
            Client = rd["Client"] is DBNull ? Client : rd["Client"].ToString();
            VendorId = rd["VendorId"] is DBNull ? VendorId : rd["VendorId"].ToString();
            VendorName = rd["VendorName"] is DBNull ? VendorName : rd["VendorName"].ToString();
            CurrencyCode = rd["CurrencyCode"] is DBNull ? CurrencyCode : rd["CurrencyCode"].ToString();
            Country = rd["Country"] is DBNull ? Country : rd["Country"].ToString();
            VendorAddress1 = rd["VendorAddress1"] is DBNull ? VendorAddress1 : rd["VendorAddress1"].ToString();
            VendorAddress2 = rd["VendorAddress2"] is DBNull ? VendorAddress2 : rd["VendorAddress2"].ToString();
            VendorPhone = rd["VendorPhone"] is DBNull ? VendorPhone : rd["VendorPhone"].ToString();
            VendorFax = rd["VendorFax"] is DBNull ? VendorFax : rd["VendorFax"].ToString();
            VendorEmailID = rd["VendorEmailID"] is DBNull ? VendorEmailID : rd["VendorEmailID"].ToString();
            PaymentTerms = rd["PaymentTerms"] is DBNull ? PaymentTerms : rd["PaymentTerms"].ToString();
            PaymentMethod = rd["PaymentMethod"] is DBNull ? PaymentMethod : rd["PaymentMethod"].ToString();
            EnabledFlag = rd["EnabledFlag"] is DBNull ? EnabledFlag : rd["EnabledFlag"].ToString();
            AddedOn = rd["AddedOn"] is DBNull ? AddedOn : Convert.ToDateTime(rd["AddedOn"]);
            PickedUpFlag = rd["PickedUpFlag"] is DBNull ? PickedUpFlag : Convert.ToInt32(rd["PickedUpFlag"]);
            PickedUpAt = rd["PickedUpAt"] is DBNull ? PickedUpAt : Convert.ToDateTime(rd["PickedUpAt"]);
            ShortName = rd["ShortName"] is DBNull ? ShortName : rd["ShortName"].ToString();
            Description = rd["Description"] is DBNull ? Description : rd["Description"].ToString();
            ResultDetails = rd["ResultDetails"] is DBNull ? ResultDetails : rd["ResultDetails"].ToString();
            ExecutionID = rd["ExecutionID"] is DBNull ? ExecutionID : rd["ExecutionID"].ToString();
        }
        public jVendors(c_supplier supplier)
        {
            Client = supplier.client;
            VendorId = supplier.apar_id;
            VendorName = supplier.apar_name;
            CurrencyCode = supplier.currency;
            Country = supplier.country_code;
            VendorAddress1 = supplier.Address;
            VendorAddress2 = "";
            VendorPhone = supplier.Telephone_1;
            VendorFax = supplier.Telephone_2;
            VendorEmailID = supplier.e_mail;
            PaymentTerms = supplier.terms_id;
            PaymentMethod = "";
            EnabledFlag = "N";
            AddedOn = DateTime.Now;
            PickedUpFlag = 0;
            PickedUpAt = DateTime.Now;
            ShortName = supplier.short_name;
            Description = "";
            ResultDetails = "";
            ExecutionID = "";
        }
    }
}
